
package com.example.cia.mysql.dao.impl;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.example.cia.mysql.dao.IAddDevice;

public class addDeviceImpl extends mysqlDaoImpl implements IAddDevice{

	@Override
	public String getTableName(){
		return "device";
	}
	
	@Override
	public boolean add(String address,String detailAddress) throws ClassNotFoundException, SQLException, IOException{
		String sql = "INSERT INTO "+getQulifiedTableName()+" (device_address,device_detail_address,device_state) VALUES(?,?,?)";
		Connection con = new databaseConnectionImpl().getCon();
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setString(1, address);
		ps.setString(2, detailAddress);
		ps.setInt(3, 0);
		return (ps.executeUpdate()!=0);
	}
}
